package com.example.job;

import io.etcd.jetcd.KV;
import io.etcd.jetcd.Lease;
import io.fury.Fury;

public interface JobService {

    public static final String JOB = "/job";

    //存储正在运行中的
    public static final String JOB_RUN = JOB + "/run/";

    //存储所有的任务，防止停机丢失
    public static final String JOB_LIST = JOB + "/list/";

    //记录当前任务执行节点
    public static final String JOB_LEADER = JOB + "/leader";

    public Fury getFury();

    public Lease getLeaseClient();

    public KV getKVClient();

    public Boolean createAndSetJobInTx(String jobId, Class<? extends Job> jobClass, long seconds) throws Exception;

    public Boolean createAndSetRepeatJobInTx(String jobId, Class<? extends Job> jobClass, long interval) throws Exception;

    public Boolean cancelJobInTx(String jobId) throws Exception;

    public Boolean updateJobInTx(String jobId, long seconds) throws Exception;
}
